title {label: "tinynote Entity-Relationship diagram", size: "24"}

# Entities

entity {size: "16", font: "Courier"}

[users] {bgcolor: "#ececfc"}
id {label: "(PK1) CHAR(36) NOT NULL"}
username {label: "(UK1) VARCHAR(32) NOT NULL"}
email {label: "(UK2) VARCHAR(255) NOT NULL"}
password {label: "VARCHAR(255) NOT NULL"}
active {label: "BOOLEAN NOT NULL DEFAULT FALSE"}
is_admin {label: "BOOLEAN NOT NULL DEFAULT FALSE"}
created_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}
updated_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}

[notes] {bgcolor: "#fbfbdb"}
id {label: "(PK1) CHAR(36) NOT NULL"}
user_id {label: "(FK1) CHAR(36) NOT NULL"}
title {label: "VARCHAR(255) NOT NULL"}
body {label: "TEXT NOT NULL"}
created_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}
updated_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}

[tags] {bgcolor: "#d0e0d0"}
id {label: "(PK1) CHAR(36) NOT NULL"}
user_id {label: "(FK1, UK1) CHAR(36) NOT NULL"}
name {label: "(UK1) VARCHAR(64) NOT NULL"}
created_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}
updated_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}

[notes_tags] {bgcolor: "#eee0a0"}
id {label: "(PK1) CHAR(36) NOT NULL"}
note_id {label: "(FK1, UK1) CHAR(36) NOT NULL"}
tag_id {label: "(FK2, UK1) CHAR(36) NOT NULL"}
created_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}
updated_at {label: "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP"}

# Relationships

users 1--* notes
users 1--* tags
notes 1--* notes_tags
tags  1--* notes_tags
